module.exports = function ($scope, $state, obj, update, $modalInstance, toaster) {

    $scope.obj = {};
    $scope.obj = obj;
    $scope.obj.loan_limit_price = 0;
    $scope.obj.picket_line = 0;
    $scope.obj.prestore_state = 0;
    $scope.obj.company_code = obj.seller_code;

    $scope.ok = function () {
        if ($scope.obj.send_sms_flag == 1) {
            if (!(/^(1[34578]\d{9},)*1[34578]\d{9}$/.test($scope.obj.send_sms_mobile))) {
                toaster.warning({title: '', body: '手机号码有误，请重填'})
                return false;
            };
        } else if ($scope.obj.send_sms_flag != 0) {
            toaster.warning({title: '', body: '请选择是否发送短信提示'})
            return false;
        }
        
        update.save($scope.obj, function (res) {
            if (res.errcode === 0) {
                toaster.success({title: '', body: '修改成功'})
                $modalInstance.close();
            }
            else {
                toaster.error({title: '', body: res.errmsg})
            }
        });
    };

    $scope.cancel = function () {
        $modalInstance.dismiss('cancel');
    };

};